/* Base styles and content styles */

@import '../fonts/fira_code.css';
@import 'variables.css';

@font-face {
  font-family: 'SourceSans3';
  src: url('../fonts/SourceSans3-Regular.otf.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'SourceSans3';
  src: url('../fonts/SourceSans3-It.otf.woff') format('woff');
  font-weight: normal;
  font-style: italic;
}

@font-face {
  font-family: 'SourceSans3';
  src: url('../fonts/SourceSans3-Semibold.otf.woff') format('woff');
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: 'SourceSans3';
  src: url('../fonts/SourceSans3-SemiboldIt.otf.woff') format('woff');
  font-weight: bold;
  font-style: italic;
}

:root {
    /* Browser default font-size is 16px, this way 1 rem = 10px */
    font-size: 62.5%;
    color-scheme: var(--color-scheme);
    /* TODO: Why is important needed here? */
    --mono-font: "Fira Code" !important;
    --mono-font-size: 1.4rem;
}

.sidebar {
    font-size: 1.6rem !important;
}
math {
    font-size: 1.9rem;
}

html {
    font-family: 'SourceSans3', sans-serif;
    color: var(--fg);
    background-color: var(--bg);
    text-size-adjust: none;
    -webkit-text-size-adjust: none;
}

body {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 400;
    overflow-x: hidden;
}

code {
    font-family: var(--mono-font) !important;
    font-weight: 500;
    font-size: var(--mono-font-size);
    direction: ltr !important;
    font-variant-ligatures: none;
}

/* make long words/inline code not x overflow */
main {
    overflow-wrap: break-word;
}

/* make wide tables scroll if they overflow */
.table-wrapper {
    overflow-x: auto;
}

/* Don't change font size in headers. */
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
    font-size: unset;
}

.left { float: left; }
.right { float: right; }
.boring { opacity: 0.6; }
.hide-boring .boring { display: none; }
.hidden { display: none !important; }

h2, h3 { margin-block-start: 2.5em; }
h4, h5 { margin-block-start: 2em; }

.header + .header h3,
.header + .header h4,
.header + .header h5 {
    margin-block-start: 1em;
}

h1:target::before,
h2:target::before,
h3:target::before,
h4:target::before,
h5:target::before,
h6:target::before {
    display: inline-block;
    content: "»";
    margin-inline-start: -30px;
    width: 30px;
}

/* This is broken on Safari as of version 14, but is fixed
   in Safari Technology Preview 117 which I think will be Safari 14.2.
   https://bugs.webkit.org/show_bug.cgi?id=218076
*/
:target {
    /* Safari does not support logical properties */
    scroll-margin-top: calc(var(--menu-bar-height) + 0.5em);
}

.page {
    outline: 0;
    padding: 0 var(--page-padding);
    margin-block-start: calc(0px - var(--menu-bar-height)); /* Compensate for the #menu-bar-hover-placeholder */
}
.page-wrapper {
    box-sizing: border-box;
    background-color: var(--bg);
}
.no-js .page-wrapper,
.js:not(.sidebar-resizing) .page-wrapper {
    transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}
[dir=rtl] .js:not(.sidebar-resizing) .page-wrapper {
    transition: margin-right 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}

.content {
    overflow-y: auto;
    padding: 0 5px 50px 5px;
}
.content main {
    margin-inline-start: auto;
    margin-inline-end: auto;
    max-width: var(--content-max-width);
}
.content p { line-height: 1.45em; }
.content ol { line-height: 1.45em; }
.content ul { line-height: 1.45em; }
.content a { text-decoration: none; }
.content a:hover { text-decoration: underline; }
.content img, .content video { max-width: 100%; }
.content .header:link,
.content .header:visited {
    color: var(--fg);
}
.content .header:link,
.content .header:visited:hover {
    text-decoration: none;
}

table {
    margin: 0 auto;
    border-collapse: collapse;
}
table td {
    padding: 3px 16px;
    border: 1px var(--table-border-color) solid;
}
table thead {
    background: var(--table-header-bg);
}
table thead td {
    font-weight: 700;
    border: none;
}
table thead th {
    padding: 3px 16px;
}
table thead tr {
    border: 1px var(--table-header-bg) solid;
}
/* Alternate background colors for rows */
table tbody tr:nth-child(2n) {
    background: var(--table-alternate-bg);
}


blockquote {
    margin: 20px 0;
    padding: 0 20px;
    color: var(--fg);
    background-color: var(--quote-bg);
    border-block-start: .1em solid var(--quote-border);
    border-block-end: .1em solid var(--quote-border);
}

.warning {
    margin: 20px;
    padding: 0 20px;
    border-inline-start: 2px solid var(--warning-border);
}

.warning:before {
    position: absolute;
    width: 3rem;
    height: 3rem;
    margin-inline-start: calc(-1.5rem - 21px);
    /*content: "ⓘ";*/
    text-align: center;
    background-color: var(--bg);
    color: var(--warning-border);
    font-weight: bold;
    font-size: 2rem;
}

blockquote .warning:before {
    background-color: var(--quote-bg);
}

kbd {
    background-color: var(--table-border-color);
    border-radius: 4px;
    border: solid 1px var(--theme-popup-border);
    box-shadow: inset 0 -1px 0 var(--theme-hover);
    display: inline-block;
    font-size: var(--code-font-size);
    font-family: var(--mono-font);
    line-height: 10px;
    padding: 4px 5px;
    vertical-align: middle;
}

:not(.footnote-definition) + .footnote-definition,
.footnote-definition + :not(.footnote-definition) {
    margin-block-start: 2em;
}
.footnote-definition {
    font-size: 0.9em;
    margin: 0.5em 0;
}
.footnote-definition p {
    display: inline;
}

.tooltiptext {
    position: absolute;
    visibility: hidden;
    color: #fff;
    background-color: #333;
    transform: translateX(-50%); /* Center by moving tooltip 50% of its width left */
    left: -8px; /* Half of the width of the icon */
    top: -35px;
    font-size: 0.8em;
    text-align: center;
    border-radius: 6px;
    padding: 5px 8px;
    margin: 5px;
    z-index: 1000;
}
.tooltipped .tooltiptext {
    visibility: visible;
}

.chapter li.part-title {
    color: var(--sidebar-fg);
    margin: 5px 0px;
    font-weight: bold;
}

.result-no-output {
    font-style: italic;
}

/* -------------------------------------------------------------- */

/* Style sheet for TONC */

dfn {
  font-style: italic;
  font-weight: bold;
}

div.note {
  border-color: var(--fg);
  background-color: var(--table-alternate-bg);
}
div.note p, div.note ul {
  margin: 6px 0;
}
div.note ul {
  padding-left: 20px;
}
div.note p + p {
  margin-top: 12px;
}

div.nh, div.nhgood, div.nhbad, div.nhcare {
  font-weight: bold;
  margin-top: 5px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--quote-border);
}

/* TODO: can we use colours from the syntax highlighting style instead? */
/*       (or just tweak them a bit per-theme) */
div.nhbad, .rem, .ack {
  color: #ec1256;
}
div.nhgood {
  color: #1ec36d;
}
div.nhcare {
  color: #e88f42;
}
.hljs span.rem, .hljs span.rem * {
  color: #ec1256;
}
.wavy {
  text-decoration: underline wavy;
}

.bold {
  font-weight: bold;
}

/* --- picture+caption frames --- */
div.cpt, div.cpt_fl, div.cpt_fr {
  margin: .5em;  padding: 4px;
  border: 1px var(--table-border-color) solid;
  background-color: var(--table-alternate-bg);
  font-size: 80%; 
  page-break-inside: avoid;
}

div.cpt_fl { float:left; }
div.cpt_fr { float:right; }

/* Margins inside tables work differently. */
td div.cpt, td div.dpt_fl, td div.cpt_fr {
  margin: 0;
}

.cpt p, .cpt_fl p, .cpt_fr p {
  margin: 0.5em 0;
}

/* --- table block styles --- */
/* yes, table and caption forms are required */

div.reg         { margin: 8px auto; text-align: center; width: 94%; }
div.reg table   { margin: 1px auto; margin-bottom: 12px; text-align: left; }
div.reg caption { margin: 0px auto; text-align: left; }

div.cblock         { margin: 6px auto; text-align: center; }
div.cblock div     { margin: 2px auto; text-align: left; }
div.cblock table   { margin: 2px auto; text-align: left; }
div.cblock caption { margin: 0px auto; text-align: left; }

/* div.lblock   { margin: 6px 3em; }
div.lblock table { margin: 2px 0;  } */

div.cblock div.cpt { margin: 0.5em auto; }

/* Fix oversight in the mdBook styles? */
table, table th {
  border: 1px var(--table-border-color) solid;
}

/* Gotta make register diagram table cells smaller so they fit on the page. */
.table-reg th,
.table-reg td {
  padding: 3px 13px;
}
/* But some are too big even still. */
table.reg-huge th,
table.reg-huge td {
  padding: 3px 7px;
}

/* === Table styles === */

td.fill, th.fill { width: 16px; }

/* --- reg table --- */
.table-reg {
  font: var(--mono-font-size) var(--mono-font);
  page-break-inside: avoid;
}
caption.reg {
  caption-side:top;
  padding-bottom: 4px;
}
caption.reg, caption.reg * {
  font-size: 1.2rem;
}
caption[align="bottom"], div.cblock caption[align="bottom"] {
  margin-top: 6px;
}

caption.reg, tr.bits {
  white-space: nowrap;
}

tr.bits, tr.bf, col.bits, col.bf, col.def { text-align: center; }
col.bits, col.bf, col.def { vertical-align: top; }
tr.bits, col.bits { font: var(--mono-font-size) var(--mono-font); }
tr.bf, col.bf { font-weight: bold; }
col.def { font: var(--mono-font-size) var(--mono-font); }

/* read only, write only */
.rof { text-decoration: overline;  color: #f22; }
.wof { text-decoration: underline; color: #44f; }

/* reg colors */
.rclr0 { color: #ef0d4b; }
.rclr1 { color: #41adff; }
.rclr2 { color: #45e774; }
.rclr3 { color: #d948d9; }
.rclr4 { color: #f9663e; }
.rclr5 { color: #d09a4c; }
.rclr6 { color: #e7849b; }
.rclr7 { color: #dce24b; }
.rclr8 { color:teal; }
.rclr9 { color:gray; }

font[color="blue"] { color: #43a8e6; }
font[color="green"] { color: #45e774; }
font[color="red"] { color: #ef0d4b; }

/* Special case table overrides (in Text systems) */
#fig\:img-fontpack, #tbl\:bupshade {

  & table {
    width: 100%;
    font-size: 90%;
    page-break-inside: avoid;
  }

  & span.rarr {
    font-size:200%;
    position: relative;
    top: 0.26em;
  }

  & td, th {
    padding: 1px 0;
  }

  & tr td, tr th {
    background-color: var(--table-alternate-bg);
    border: none;
    text-align: center;
  }

  & .table-reg th, .table-reg td {
    padding: 1px 3px;
    font-family: 'SourceSans3';
  }

  & .bdrT, .bdrTL, .bdrTR, .bdrLL, .bdrRR {
    border-top: 1px var(--fg) solid;
  }

  & .bdrL, .bdrTL, .bdrBL, .bdrLL {
    border-left: 1px var(--fg) solid;
  }
  & .bdrB, .bdrBL, .bdrBR, .bdrLL, .bdrRR {
    border-bottom: 1px var(--fg) solid;
  }

  & .bdrR, .bdrTR, .bdrBR, .bdrRR {
    border-right: 1px var(--fg) solid;
  }
}

#tbl\:bupshade {
  width: 300px;
  margin: 0px 10px;
}

/* --- */

.menu-title {
  font-weight: 400;
  font-size: 2.75rem;
  letter-spacing: -0.02em;
  /* equals -2% */
}

.box {
  margin: 20px 0;
  padding: 1.6px 20px;
  border-left-width: 0.75rem;
  border-left-style: solid;
}

.box > .box-title {
  font-weight: 600;
  text-transform: uppercase;
}

.box.tip {
  border-color: #42b983;
  background-color: var(--quote-bg);
}

.box.warning {
  border-left-color: var(--c-warning);
  background-color: rgba(255, 229, 100, 0.2);
  color: var(--c-warning-text);
}

.box.warning > .box-title {
  color: var(--c-warning-title);
}

.box.danger {
    border-left-color: var(--c-danger);
    background-color: rgba(255, 0, 0, .15);
    color: var(--c-danger-text);
}

.box.danger > .box-title {
    color: var(--c-danger-title);
}

.spacer {
  width: 100%;
  height: 3px;
  margin: 25px 0px 25px 0px;
}

/* Global CSS variables */

:root {
    /* (Override) workaround to get hover+active sidebar links on normal links blue */
    --sidebar-active: var(--links);
    /* Warning boxes base styling */
    --c-warning: #e7c000;
    --c-warning-bg: #fffae3;
    --c-warning-title: #ad9000;
    /* Danger boxes base styling */
    --c-danger: #cc0000;
    --c-danger-text: #660000;
    --c-danger-title: #990000;
}

/* Theme-wide CSS variables */

.ayu {
    --c-warning-text: #eac100;
    --c-danger-text: #ff2929;
    --c-danger-title: #dc0000;
}

.coal {
    --c-warning-text: #eac100;
    --c-danger-text: #ff2929;
    --c-danger-title: #dc0000;
}

.light {
  --c-warning-text: #746000;
}

.navy {
    --c-warning-text: #eac100;
    --c-danger-text: #ff2929;
    --c-danger-title: #dc0000;
}

.rust {
  --c-warning-text: #ad8e00;
}

